---
title: Add not null constraint
description: Add not null operations add a `NOT NULL` constraint to a column.
---

## Structure

<YamlJsonTabs>
```yaml
alter_column:
  table: table name
  column: column name
  nullable: false
  up: SQL expression
  down: SQL expression
```
```json
{
  "alter_column": {
    "table": "table name",
    "column": "column name",
    "nullable": false,
    "up": "SQL expression",
    "down": "SQL expression"
  }
}
```
</YamlJsonTabs>

Use `up` to migrate values from the nullable column in the old schema view to the `NOT NULL` column in the new schema version. `down` is used to migrate values in the other direction.

## Examples

### Add a `NOT NULL` constraint

Add a `NOT NULL` constraint to the `review` column in the `reviews` table.

<ExampleSnippet example="16_set_nullable.yaml" languange="yaml" />
